from bs4 import BeautifulSoup
data=''
with open('shijiazhuangWeather1102.html','r',encoding='utf-8') as f:
    data=f.read()
soup = BeautifulSoup(data, 'lxml')
lis = soup.select("ul[class= 't clearfix'] li")#7个li
with open('weather.csv','w',encoding='utf-8') as file:
    for li in lis:
        date = li.select('h1')[0].text
        weather = li.select("p[class = 'wea']")[0].text
        tem = li.select("p[class = 'tem'] span")[0].text + "/" + li.select("p[class = 'tem'] i")[0].text
        print(f"{date}的天气：{weather}，气温：{tem}")
        file.write(f"{date}的天气是{weather}气温是{tem}"+'\n')